home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / install / data.z / TYPINFO.INT < prev    next >
Encoding:
Text File  |  1997-08-05  |  4.6 KB  |  148 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit TypInfo;
  11.  
  12. interface
  13.  
  14. uses SysUtils;
  15.  
  16. type
  17.  
  18.   TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat,
  19.     tkString, tkSet, tkClass, tkMethod, tkWChar, tkLString, tkWString,
  20.     tkVariant, tkArray, tkRecord, tkInterface);
  21.   TTypeKinds = set of TTypeKind;
  22.  
  23.   TOrdType = (otSByte, otUByte, otSWord, otUWord, otSLong);
  24.  
  25.   TFloatType = (ftSingle, ftDouble, ftExtended, ftComp, ftCurr);
  26.  
  27.   TMethodKind = (mkProcedure, mkFunction, mkSafeProcedure, mkSafeFunction);
  28.   TParamFlags = set of (pfVar, pfConst, pfArray, pfAddress, pfReference, pfOut);
  29.   TIntfFlags = set of (ifHasGuid, ifDispInterface, ifDispatch);
  30.  
  31.   PPTypeInfo = ^PTypeInfo;
  32.   PTypeInfo = ^TTypeInfo;
  33.   TTypeInfo = record
  34.     Kind: TTypeKind;
  35.     Name: ShortString;
  36.    {TypeData: TTypeData}
  37.   end;
  38.  
  39.   PTypeData = ^TTypeData;
  40.   TTypeData = packed record
  41.     case TTypeKind of
  42.       tkUnknown, tkLString, tkWString, tkVariant: ();
  43.       tkInteger, tkChar, tkEnumeration, tkSet, tkWChar: (
  44.         OrdType: TOrdType;
  45.         case TTypeKind of
  46.           tkInteger, tkChar, tkEnumeration, tkWChar: (
  47.             MinValue: Longint;
  48.             MaxValue: Longint;
  49.             case TTypeKind of
  50.               tkInteger, tkChar, tkWChar: ();
  51.               tkEnumeration: (
  52.                 BaseType: PPTypeInfo;
  53.                 NameList: ShortString));
  54.           tkSet: (
  55.             CompType: PPTypeInfo));
  56.       tkFloat: (
  57.         FloatType: TFloatType);
  58.       tkString: (
  59.         MaxLength: Byte);
  60.       tkClass: (
  61.         ClassType: TClass;
  62.         ParentInfo: PPTypeInfo;
  63.         PropCount: SmallInt;
  64.         UnitName: ShortString
  65.        {PropData: TPropData});
  66.       tkMethod: (
  67.         MethodKind: TMethodKind;
  68.         ParamCount: Byte;
  69.         ParamList: array[0..1023] of Char
  70.        {ParamList: array[1..ParamCount] of
  71.           record
  72.             Flags: TParamFlags;
  73.             ParamName: ShortString;
  74.             TypeName: ShortString;
  75.           end;
  76.         ResultType: ShortString});
  77.       tkInterface: (
  78.         IntfParent : PPTypeInfo; { ancestor }
  79.         IntfFlags : TIntfFlags;
  80.         GUID : TGUID;
  81.         IntfUnit : ShortString;
  82.        {PropData: TPropData});
  83.   end;
  84.  
  85.   TPropData = packed record
  86.     PropCount: Word;
  87.     PropList: record end;
  88.    {PropList: array[1..PropCount] of TPropInfo}
  89.   end;
  90.  
  91.   PPropInfo = ^TPropInfo;
  92.   TPropInfo = packed record
  93.     PropType: PPTypeInfo;
  94.     GetProc: Pointer;
  95.     SetProc: Pointer;
  96.     StoredProc: Pointer;
  97.     Index: Integer;
  98.     Default: Longint;
  99.     NameIndex: SmallInt;
  100.     Name: ShortString;
  101.   end;
  102.  
  103.   TPropInfoProc = procedure(PropInfo: PPropInfo) of object;
  104.  
  105.   PPropList = ^TPropList;
  106.   TPropList = array[0..16379] of PPropInfo;
  107.  
  108. const
  109.   tkAny = [Low(TTypeKind)..High(TTypeKind)];
  110.   tkMethods = [tkMethod];
  111.   tkProperties = tkAny - tkMethods - [tkUnknown];
  112.  
  113. { Property access routines }
  114.  
  115. function GetTypeData(TypeInfo: PTypeInfo): PTypeData;
  116.  
  117. function GetEnumName(TypeInfo: PTypeInfo; Value: Integer): string;
  118. function GetEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer;
  119.  
  120. function GetPropInfo(TypeInfo: PTypeInfo; const PropName: string): PPropInfo;
  121. procedure GetPropInfos(TypeInfo: PTypeInfo; PropList: PPropList);
  122. function GetPropList(TypeInfo: PTypeInfo; TypeKinds: TTypeKinds;
  123.   PropList: PPropList): Integer;
  124.  
  125. function IsStoredProp(Instance: TObject; PropInfo: PPropInfo): Boolean;
  126.  
  127. function GetOrdProp(Instance: TObject; PropInfo: PPropInfo): Longint;
  128. procedure SetOrdProp(Instance: TObject; PropInfo: PPropInfo;
  129.   Value: Longint);
  130.  
  131. function GetStrProp(Instance: TObject; PropInfo: PPropInfo): string;
  132. procedure SetStrProp(Instance: TObject; PropInfo: PPropInfo;
  133.   const Value: string);
  134.  
  135. function GetFloatProp(Instance: TObject; PropInfo: PPropInfo): Extended;
  136. procedure SetFloatProp(Instance: TObject; PropInfo: PPropInfo;
  137.   Value: Extended);
  138.  
  139. function GetVariantProp(Instance: TObject; PropInfo: PPropInfo): Variant;
  140. procedure SetVariantProp(Instance: TObject; PropInfo: PPropInfo;
  141.   const Value: Variant);
  142.  
  143. function GetMethodProp(Instance: TObject; PropInfo: PPropInfo): TMethod;
  144. procedure SetMethodProp(Instance: TObject; PropInfo: PPropInfo;
  145.   const Value: TMethod);
  146.  
  147. implementation
  148.